//
//  ViewController.swift
//  RtspClient
//
//  Created by Teocci on 18/05/16.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var imageView: UIImageView!
    var video: RTSPPlayer!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        video = RTSPPlayer(video: "rtsp://192.168.8.1:554/livestream/1", usesTcp: false)
        //video.outputWidth = Int32(UIScreen.main.bounds.width)
        //video.outputHeight = Int32(UIScreen.main.bounds.height)
        video.outputWidth = 300*3; // 设置分辨率
        video.outputHeight = 225*3;
        video.seekTime(0.0)
        
        let timer = Timer.scheduledTimer(timeInterval: 1.0/30, target: self, selector: #selector(ViewController.update), userInfo: nil, repeats: true)
        timer.fire()
    }
    
  @objc func update(timer: Timer) {
        if(!video.stepFrame()){
            timer.invalidate()
            video.closeAudio()
        }
        imageView.image = video.currentImage
    }

}

